package com.cuitrip.util;

import android.os.Build;


import com.lab.logtrack.AppLog;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


/**
 * Created by ak
 */
public class PhoneUtil {

    // 判断是不是MIUI V5 V6
    public static boolean isXiaomiV5orV6(){
        String uiName = getSystemProperty("ro.miui.ui.version.name");
        if (uiName != null && (("V5").equals(uiName.trim()) || ("V6").equals(uiName.trim())) ){
            return true;
        }
        return false;
    }

    public static String getSystemProperty(String propName) {
        String line;
        BufferedReader input = null;
        try {
            Process p = Runtime.getRuntime().exec("getprop " + propName);
            input = new BufferedReader(new InputStreamReader(p.getInputStream()), 1024);
            line = input.readLine();
            input.close();
        } catch (IOException ex) {
            AppLog.e("Unable to read sysprop " + propName + " " + ex);
            return null;
        } finally {
            if (input != null) {
                try {
                    input.close();
                } catch (IOException e) {
                    AppLog.e("Exception while closing InputStream" + e);
                }
            }
        }
        return line;
    }

    //是否是genymotion 模拟器, 貌似都是这个名字
    public static boolean isGenymotion() {
        return Build.DEVICE.equals("vbox86p");
    }
}
